package com.group4.admin.beans;

import com.group4.entity.Student;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.ManagedProperty;
import javax.faces.bean.RequestScoped;
import javax.faces.event.ActionEvent;

/**
 * Controlles the adminStudents.xhtml
 * 
 * @author andake, anjonas
 */
@ManagedBean
@RequestScoped
public class AdminStudentsControllerBean {
    
    @ManagedProperty(value="#{adminStudentsBackingBean}")
    AdminStudentsBackingBean asb;

    /** Creates a new instance of AdminStudentsControllerBean */
    public AdminStudentsControllerBean() {
    }

    public AdminStudentsBackingBean getAsb() {
        return asb;
    }

    public void setAsb(AdminStudentsBackingBean asb) {
        this.asb = asb;
    }
    
    // Listens for add student event
    public void addNewStudent() {
        asb.addStudent();
    }
    
    // listens for delete student event
    public void deleteStudent(ActionEvent e) {
        Student s = (Student) e.getComponent().getAttributes().get("student");
        asb.deleteStudent(s);
    }
}
